package com.yaoyao.HelloWorld;

import java.util.Random;
import java.util.Scanner;

public class exercise2 {
    public static void main(String[] args) {
        Random ra = new Random();
        int num = ra.nextInt(1, 101);
        System.out.println(num);
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入您猜测的数字");
            int guess = sc.nextInt();
            System.out.println("您猜测的数字为" + guess);
            if (guess > 1 && guess < 100) {
                if (guess > num) {
                    System.out.println("您猜测的数字过大，请重新猜测");
//                    guess= sc.nextInt();
                } else if (guess < num) {
                    System.out.println("您猜测的数字过小，请重新猜测");
//                    guess= sc.nextInt();
                } else {
                    System.out.println("恭喜您答对啦！！！");
                    break;
                }
            } else {
                System.out.println("您输入的数字不在范围内或者不是整数,请重新输入");
            }
        }
    }
}
